package com.neulogistics.contrib.transfercenter.infrastructure.persistence.orm.po;

import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;

/**
 * 调拨单表
 * @TableName tb_transfer_order
 */
@TableName(value ="tb_transfer_order", autoResultMap = true)
@Data
public class TransferOrderPO implements Serializable {
    /**
     * 调拨单id
     */
    @TableId(value = "transfer_order_id", type = IdType.INPUT)
    private Long transferOrderId;

    /**
     * 调度类型：1:配送；2:退货；3:换货
     */
    @TableField(value = "transfer_type")
    private Integer transferType;

    /**
     * 调度单状态：0:待调度：1:已调度；2:挂起
     */
    @TableField(value = "transfer_status")
    private Integer transferStatus;

    /**
     * 订单id
     */
    @TableField(value = "order_id")
    private Long orderId;

    /**
     * 关联任务单id
     */
    @TableField(value = "task_id")
    private Long taskId;

    /**
     * 出库库房id
     */
    @TableField(value = "outbound_warehouse_id")
    private Integer outboundWarehouseId;

    /**
     * 入库库房id
     */
    @TableField(value = "inbound_warehouse_id")
    private Integer inboundWarehouseId;

    /**
     * 订单项 [{商品id、名称、数量、单价、计量单位}]
     */
    @TableField(value = "order_items", typeHandler = JacksonTypeHandler.class)
    private JSONArray orderItems;

    /**
     * 计划出库时间
     */
    @TableField(value = "exp_outbound_time")
    private Date expOutboundTime;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 创建人id
     */
    @TableField(value = "creator_id")
    private Integer creatorId;

    /**
     * 是否删除
     */
    @TableField(value = "deleted")
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        TransferOrderPO other = (TransferOrderPO) that;
        return (this.getTransferOrderId() == null ? other.getTransferOrderId() == null : this.getTransferOrderId().equals(other.getTransferOrderId()))
            && (this.getTransferStatus() == null ? other.getTransferStatus() == null : this.getTransferStatus().equals(other.getTransferStatus()))
            && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
            && (this.getTaskId() == null ? other.getTaskId() == null : this.getTaskId().equals(other.getTaskId()))
            && (this.getOutboundWarehouseId() == null ? other.getOutboundWarehouseId() == null : this.getOutboundWarehouseId().equals(other.getOutboundWarehouseId()))
            && (this.getInboundWarehouseId() == null ? other.getInboundWarehouseId() == null : this.getInboundWarehouseId().equals(other.getInboundWarehouseId()))
            && (this.getOrderItems() == null ? other.getOrderItems() == null : this.getOrderItems().equals(other.getOrderItems()))
            && (this.getExpOutboundTime() == null ? other.getExpOutboundTime() == null : this.getExpOutboundTime().equals(other.getExpOutboundTime()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getTransferOrderId() == null) ? 0 : getTransferOrderId().hashCode());
        result = prime * result + ((getTransferStatus() == null) ? 0 : getTransferStatus().hashCode());
        result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
        result = prime * result + ((getTaskId() == null) ? 0 : getTaskId().hashCode());
        result = prime * result + ((getOutboundWarehouseId() == null) ? 0 : getOutboundWarehouseId().hashCode());
        result = prime * result + ((getInboundWarehouseId() == null) ? 0 : getInboundWarehouseId().hashCode());
        result = prime * result + ((getOrderItems() == null) ? 0 : getOrderItems().hashCode());
        result = prime * result + ((getExpOutboundTime() == null) ? 0 : getExpOutboundTime().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getCreatorId() == null) ? 0 : getCreatorId().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", transferOrderId=").append(transferOrderId);
        sb.append(", transferStatus=").append(transferStatus);
        sb.append(", orderId=").append(orderId);
        sb.append(", taskId=").append(taskId);
        sb.append(", outboundWarehouseId=").append(outboundWarehouseId);
        sb.append(", inboundWarehouseId=").append(inboundWarehouseId);
        sb.append(", orderItems=").append(orderItems);
        sb.append(", expOutboundTime=").append(expOutboundTime);
        sb.append(", createTime=").append(createTime);
        sb.append(", creatorId=").append(creatorId);
        sb.append(", deleted=").append(deleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}